#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

class Solution {
    public:
        void setZeroes(vector<vector<int> > &matrix) {
            int row = matrix.size();
            int col = matrix[0].size();
            vector<int> rowHash(row, 0);
            vector<int> colHash(col, 0);
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) 
                    if(matrix[i][j] == 0) {
                        rowHash[i] = 1;
                        colHash[j] = 1; 
                    }
            }

            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    if (rowHash[i] == 1 || colHash[j] == 1)
                        matrix[i][j] = 0;        
                }
            }
        }
};

//test in 1337 online judge
int main(int argc, char **argv)
{
    Solution mySolution;
    vector<vector<int> > matrix;
    vector<int> input;
    input.push_back(-1);
    input.push_back(0);
    input.push_back(1);
    input.push_back(2);
    input.push_back(3);
    matrix.push_back(input);
    cout << "-----------------Test 1--------------------" << endl;
    mySolution.setZeroes(matrix);
    for (int i = 0; i < matrix.size(); i++) {
        for (int j = 0; j < matrix[0].size(); j++)
            cout << matrix[i][j] << " ";
        cout << endl;
    }

    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
